﻿Imports System
Imports System.ComponentModel
Imports System.Security
Imports System.Security.Permissions
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.Design
Imports System.Web.UI.WebControls
Imports System.ComponentModel.Design
Imports System.Data.SqlClient
Imports System.Drawing
Imports System.Drawing.Design

<Assembly: TagPrefix("Lnc.Web.Social.Facebook.IFrame", "fbf")> 
Namespace Facebook.IFrame

#Region "Controles"

    ''' <summary>
    ''' Plugin del Activity Feed de Facebook bajo IFrame
    ''' </summary>
    ''' <remarks>
    ''' Para poder utilizar los controles sociales de Facebook, es necesario incluir los siguientes espacios de nombres xml
    ''' en el encabezado de la página:
    ''' 
    ''' xmlns:fb="http://ogp.me/ns/fb#" (Controles Facebook)
    ''' xmlns:og="http://ogp.me/ns#"    (Controles OpenGraph)
    ''' 
    ''' El equipo de LNC Producciones
    ''' </remarks>
    <Designer(GetType(ActivityDesigner)), _
    Description("Plugin del Activity Feed de Facebook bajo IFrame"), _
    AspNetHostingPermission( _
    SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal), _
    AspNetHostingPermission( _
    SecurityAction.InheritanceDemand, _
    Level:=AspNetHostingPermissionLevel.Minimal), _
    Utils.ToolboxTabName("FB.IFrame"), _
    ToolboxData("<{0}:Activity ID=""Activity"" runat=""server""></{0}:Activity>")> _
    <ToolboxBitmap(GetType(ResourceFinder), "FbActivityFeed.bmp")> _
    Public Class Activity
        Inherits WebControl

        <Browsable(True), Category("Atributos"), _
        DefaultValue(""), _
        Description("URL del dominio al que se le mostrará actividad. Incluya solo el nombre de dominio, sin el http:// ni la ruta de la página."), _
        Editor("System.Web.UI.Design.UrlEditor", GetType(System.Drawing.Design.UITypeEditor))> _
        Public Property Domain As String = ""

        <Browsable(True), Category("Atributos"), _
        DefaultValue(""), _
        Description("Lista de las acciones a mostrar en la actividad.")> _
        Public Property Action As String = ""

        <Browsable(True), Category("Atributos"), _
        DefaultValue(""), _
        Description("mostrará todas las acciones, personalizadas y globales, asociados a esta app_id.")> _
        Public Property AppId As String = ""

        <Browsable(True), Category("Atributos"), _
        DefaultValue(300), _
        Description("El ancho del plugin en pixeles. El valor predeterminado es de 300px.")> _
        Public Overrides Property Width As System.Web.UI.WebControls.Unit = 300

        <Browsable(True), Category("Atributos"), _
        DefaultValue(300), _
        Description("El alto del plugin en pixeles. El valor predeterminado es de 300px.")> _
        Public Overrides Property Height As System.Web.UI.WebControls.Unit = 300

        <Browsable(True), Category("Atributos"), _
        DefaultValue(True), _
        Description("Indica si se debe mostrar el encabezado del control.")> _
        Public Property Header As Boolean = True

        <Browsable(True), Category("Atributos"), _
        DefaultValue(Common.PluginColorSchemes.Light), _
        Description("Color de esquema del control.")> _
        Public Property ColorScheme As Common.PluginColorSchemes = Common.PluginColorSchemes.Light

        <Browsable(True), Category("Atributos"), _
        DefaultValue(Common.PluginFonts.Arial), _
        Description("Fuente con la que se mostrará el plugin. El valor predeterminado es Arial.")> _
        Public Property FontName As Common.PluginFonts = Common.PluginFonts.Arial

        <Browsable(True), Category("Atributos"), _
        DefaultValue("navy"), _
        Description("Color de borde del plugin."), _
        Editor("System.Web.UI.Design.ColorBuilder", GetType(System.Drawing.Design.UITypeEditor))> _
        Public Overrides Property BorderColor As System.Drawing.Color = System.Drawing.Color.Navy

        <Browsable(True), Category("Atributos"), _
        DefaultValue(True), _
        Description("Indica si se deben mostrar las recomendaciones en el control. Si el valor se establece a VERDADERO las recomendaciones se visualizarán en la mitad inferior del control.")> _
        Public Property Recommendations As Boolean = True

        Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
            Dim text As String = ""
            text = "<iframe src=""//www.facebook.com/plugins/activity.php?site=" & Domain & _
                    "&amp;width=" & Width.Value & "&amp;height=" & Height.Value & "&amp;header=" & Utils.Funciones.ToHtmlBoolean(Header) & _
                    "&amp;colorscheme=light&amp;linktarget=_blank&amp;border_color&amp;font&amp;recommendations=" & _
                    Utils.Funciones.ToHtmlBoolean(Recommendations) & "&amp;appId=199842536770274"" scrolling=""no"" frameborder=""0"" " & _
                    "style=""border:none; overflow:hidden; width:" & Width.Value & "px; height:" & Height.Value & "px;"" " & _
                    "allowtransparency=""true""></iframe>"
            writer.Write(text)
        End Sub

    End Class

    ''' <summary>
    ''' Plugin de recomendaciones de Facebook bajo IFrame
    ''' </summary>
    ''' <remarks>
    ''' Para poder utilizar los controles sociales de Facebook, es necesario incluir los siguientes espacios de nombres xml
    ''' en el encabezado de la página:
    ''' 
    ''' xmlns:fb="http://ogp.me/ns/fb#" (Controles Facebook)
    ''' xmlns:og="http://ogp.me/ns#"    (Controles OpenGraph)
    ''' 
    ''' El equipo de LNC Producciones
    ''' </remarks>
    <Designer(GetType(RecommendationsDesigner)), _
    Description("Plugin de recomendaciones bajo IFrame"), _
    AspNetHostingPermission( _
    SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal), _
    AspNetHostingPermission( _
    SecurityAction.InheritanceDemand, _
    Level:=AspNetHostingPermissionLevel.Minimal), _
    Utils.ToolboxTabName("FB.IFrame"), _
    ToolboxData("<{0}:Recommendations ID=""Recommendations"" runat=""server""></{0}:Recommendations>")> _
    <ToolboxBitmap(GetType(ResourceFinder), "FbRecommendations.bmp")> _
    Public Class Recommendations
        Inherits WebControl

        <Browsable(True), Category("Atributos"), _
        DefaultValue(""), _
        Description("URL del dominio al que se le mostrará actividad. Incluya solo el nombre de dominio, sin el http:// ni la ruta de la página."), _
        Editor("System.Web.UI.Design.UrlEditor", GetType(System.Drawing.Design.UITypeEditor))> _
        Public Property Domain As String = ""

        <Browsable(True), Category("Atributos"), _
        DefaultValue(300), _
        Description("El ancho del plugin en pixeles. El valor predeterminado es de 300px.")> _
        Public Overrides Property Width As System.Web.UI.WebControls.Unit = 300

        <Browsable(True), Category("Atributos"), _
        DefaultValue(300), _
        Description("El alto del plugin en pixeles. El valor predeterminado es de 300px.")> _
        Public Overrides Property Height As System.Web.UI.WebControls.Unit = 300

        <Browsable(True), Category("Atributos"), _
        DefaultValue(True), _
        Description("Indica si se debe mostrar el encabezado del control.")> _
        Public Property Header As Boolean = True

        Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
            Dim text As String = ""
            text = "<iframe src=""//www.facebook.com/plugins/recommendations.php?site=" & Domain & _
                   "&amp;width=" & Width.Value & "&amp;height=" & Height.Value & "&amp;header=" & Utils.Funciones.ToHtmlBoolean(Header) & _
                   "&amp;colorscheme=light&amp;linktarget=_blank&amp;border_color&amp;font&amp;appId=199842536770274"" " & _
                   "scrolling=""no"" frameborder=""0"" style=""border:none; overflow:hidden; width:" & Width.Value & _
                   "px; height:" & Height.Value & "px;"" allowtransparecy=""true""></iframe>"
            writer.Write(text)
        End Sub

    End Class

    ''' <summary>
    ''' Boton de suscribir en Facebook bajo IFrame
    ''' </summary>
    ''' <remarks>
    ''' Para poder utilizar los controles sociales de Facebook, es necesario incluir los siguientes espacios de nombres xml
    ''' en el encabezado de la página:
    ''' 
    ''' xmlns:fb="http://ogp.me/ns/fb#" (Controles Facebook)
    ''' xmlns:og="http://ogp.me/ns#"    (Controles OpenGraph)
    ''' 
    ''' El equipo de LNC Producciones
    ''' </remarks>
    <Designer(GetType(SuscribeDesigner)), _
    Description("Boton de suscribir en Facebook bajo IFrame"), _
    AspNetHostingPermission( _
    SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal), _
    AspNetHostingPermission( _
    SecurityAction.InheritanceDemand, _
    Level:=AspNetHostingPermissionLevel.Minimal), _
    Utils.ToolboxTabName("FB.IFrame"), _
    ToolboxData("<{0}:Suscribe ID=""Suscribe"" runat=""server""></{0}:suscribe>")> _
    <ToolboxBitmap(GetType(ResourceFinder), "FbSuscribe.bmp")> _
    Public Class Suscribe
        Inherits WebControl

        <Browsable(True), Category("Atributos"), _
        DefaultValue(""), _
        Description("URL de la página donde esta incrustado el plugin."), _
        Editor("System.Web.UI.Design.UrlEditor", GetType(System.Drawing.Design.UITypeEditor))> _
        Public Property HRef As String = ""

        <Browsable(True), Category("Atributos"), _
        DefaultValue(300), _
        Description("El ancho del plugin en pixeles. El valor predeterminado es de 300px.")> _
        Public Overrides Property Width As System.Web.UI.WebControls.Unit = 300

        <Browsable(True), Category("Atributos"), _
        DefaultValue(True), _
        Description("Indica si se deben mostrar los rostros de los suscriptores.")> _
        Public Property ShowFaces As Boolean = True

        Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
            Dim text As String = ""
            text = "<iframe src=""//www.facebook.com/plugins/suscribe.php?href=" & HRef & _
                   "&amp;layout=standard&amp;show_faces=" & Utils.Funciones.ToHtmlBoolean(ShowFaces) & _
                   "&amp;colorscheme=light&amp;font&amp;width=" & Width.Value & _
                   "&amp;appId=199842536770274"" scrolling=""no"" frameborder=""0"" style=""border:none; overflow:hidden; " & _
                   "width: " & Width.Value & "px;"" allowtransparency=""true""></iframe>"
            writer.Write(text)
        End Sub

    End Class

    ''' <summary>
    ''' Plugin del LikeBox de Facebook bajo IFrame
    ''' </summary>
    ''' <remarks>
    ''' Para poder utilizar los controles sociales de Facebook, es necesario incluir los siguientes espacios de nombres xml
    ''' en el encabezado de la página:
    ''' 
    ''' xmlns:fb="http://ogp.me/ns/fb#" (Controles Facebook)
    ''' xmlns:og="http://ogp.me/ns#"    (Controles OpenGraph)
    ''' 
    ''' El equipo de LNC Producciones
    ''' </remarks>
    <Designer(GetType(LikeBoxDesigner)), _
    Description("Plugin del LikeBox de Facebook bajo IFrame"), _
    AspNetHostingPermission( _
    SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal), _
    AspNetHostingPermission( _
    SecurityAction.InheritanceDemand, _
    Level:=AspNetHostingPermissionLevel.Minimal), _
    Utils.ToolboxTabName("FB.IFrame"), _
    ToolboxData("<{0}:LikeBox ID=""LikeBox"" runat=""server""></{0}:LikeBox>")> _
    <ToolboxBitmap(GetType(ResourceFinder), "FbLikeBox.bmp")> _
    Public Class LikeBox
        Inherits WebControl

        <Browsable(True), Category("Atributos"), _
        DefaultValue(""), _
        Description("URL de la página donde esta incrustado el plugin."), _
        Editor("System.Web.UI.Design.UrlEditor", GetType(System.Drawing.Design.UITypeEditor))> _
        Public Property HRef As String = ""

        <Browsable(True), Category("Atributos"), _
        DefaultValue(Common.PluginColorSchemes.Light), _
        Description("Color de esquema del control.")> _
        Public Property ColorScheme As Common.PluginColorSchemes = Common.PluginColorSchemes.Light

        <Browsable(True), Category("Atributos"), _
        DefaultValue(True), _
        Description("Indica si se deben mostrar los rostros de los suscriptores.")> _
        Public Property ShowFaces As Boolean = True

        <Browsable(True), Category("Atributos"), _
        DefaultValue("navy"), _
        Description("Color de borde del plugin."), _
        Editor("System.Web.UI.Design.ColorBuilder", GetType(System.Drawing.Design.UITypeEditor))> _
        Public Overrides Property BorderColor As System.Drawing.Color = System.Drawing.Color.Navy

        <Browsable(True), Category("Atributos"), _
        DefaultValue(True), _
        Description("Indica si se debe mostrar el resumen de publicaciones.")> _
        Public Property ShowStream As Boolean = True

        <Browsable(True), Category("Atributos"), _
        DefaultValue(True), _
        Description("Indica si se debe mostrar el encabezado del plugin.")> _
        Public Property ShowHeader As Boolean = True

        <Browsable(True), Category("Atributos"), _
        DefaultValue(True)> _
        Public Property ForceWall As Boolean = True

        <Browsable(True), Category("Atributos"), _
        DefaultValue(300), _
        Description("El alto del plugin en pixeles. El valor predeterminado es de 300px.")> _
        Public Overrides Property Height As System.Web.UI.WebControls.Unit = 300

        <Browsable(True), Category("Atributos"), _
        DefaultValue(300), _
        Description("El ancho del plugin en pixeles. El valor predeterminado es de 300px.")> _
        Public Overrides Property Width As System.Web.UI.WebControls.Unit = 300

        Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
            Dim text As String = ""
                Text = "<iframe src=""//www.facebook.com/plugins/likebox.php?"
            text &= "href=" & HRef & "&amp;"
            text &= "width=" & Width.Value & "&amp;"
            text &= "height=" & Height.Value & "&amp;"
            text &= "colorscheme=" & Utils.Funciones.GetColorScheme(ColorScheme) & "&amp;"
            text &= "show_faces=" & Utils.Funciones.ToHtmlBoolean(ShowFaces) & "&amp;"
            text &= "border_color=" & ColorTranslator.ToHtml(BorderColor) & "&amp;"
            text &= "stream=" & Utils.Funciones.ToHtmlBoolean(ShowStream) & "&amp;"
            text &= "header=" & Utils.Funciones.ToHtmlBoolean(ShowHeader) & "&amp;"
            text &= "appId=199842536770274"" scrolling=""no"" frameborder=""0"" style=""border:none; overflow:hidden; width:" & Width.Value & "px; height:" & Height.Value & "px;"" allowTransparency=""true""></iframe>"
            writer.Write(text)
        End Sub

    End Class

    ''' <summary>
    ''' Boton de "Me Gusta" de Facebook bajo IFrame
    ''' </summary>
    ''' <remarks>
    ''' Para poder utilizar los controles sociales de Facebook, es necesario incluir los siguientes espacios de nombres xml
    ''' en el encabezado de la página:
    ''' 
    ''' xmlns:fb="http://ogp.me/ns/fb#" (Controles Facebook)
    ''' xmlns:og="http://ogp.me/ns#"    (Controles OpenGraph)
    ''' 
    ''' El equipo de LNC Producciones
    ''' </remarks>
    <Designer(GetType(LikeButtonDesigner)), _
    Description("Boton de ""Me Gusta"" de Facebook bajo IFrame"), _
    AspNetHostingPermission( _
    SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal), _
    AspNetHostingPermission( _
    SecurityAction.InheritanceDemand, _
    Level:=AspNetHostingPermissionLevel.Minimal), _
    Utils.ToolboxTabName("FB.IFrame"), _
    ToolboxData("<{0}:LikeButton ID=""LikeButton"" runat=""server""></{0}:LikeButton>")> _
    <ToolboxBitmap(GetType(ResourceFinder), "FbLikeButton.bmp")> _
    Public Class LikeButton
        Inherits WebControl

        <Browsable(True), Category("Atributos"), _
        DefaultValue(""), _
        Description("URL de la página donde esta incrustado el plugin."), _
        Editor("System.Web.UI.Design.UrlEditor", GetType(System.Drawing.Design.UITypeEditor))> _
        Public Property HRef As String = ""

        <Browsable(True), Category("Atributos"), _
        DefaultValue(True), _
        Description("Indica si se muestra el boton de Enviar a un amigo.")> _
        Public Property Send As Boolean = True

        <Browsable(True), Category("Atributos"), _
        DefaultValue(Common.LikeButtonLayouts.Standar), _
        Description("Especifica el diseño del objeto.")> _
        Public Property Layout As Common.LikeButtonLayouts = Common.LikeButtonLayouts.Standar

        <Browsable(True), Category("Atributos"), _
        DefaultValue(True), _
        Description("Indica si se debe mostrar el resumen de publicaciones.")> _
        Public Property ShowStream As Boolean = True

        <Browsable(True), Category("Atributos"), _
        DefaultValue(True), _
        Description("Indica si se debe mostrar el avatar de los usuarios que le dieron a Me Gusta.")> _
        Public Property ShowFaces As Boolean = True

        <Browsable(True), Category("Atributos"), _
        DefaultValue(300), _
        Description("El ancho del plugin en pixeles. El valor predeterminado es de 300px.")> _
        Public Overrides Property Width As System.Web.UI.WebControls.Unit = 300

        Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
            Dim text As String = ""
            text = "<iframe src=""//www.facebook.com/plugins/like.php?href=" & HRef & _
                   "&amp;send=false"
            If Layout <> Common.LikeButtonLayouts.Standar Then
                text &= "&amp;layout=" & Utils.Funciones.GetLikeButtonLayout(Layout)
            Else
                text &= "&amp;layout=standard"
            End If
            text &= "&amp;width=" & Width.Value & "&amp;show_faces=" & _
                   Utils.Funciones.ToHtmlBoolean(ShowFaces) & "&amp;action=like&amp;colorscheme=light&amp;font&amp;height=80" & _
                   "&amp;appId=199842536770274"" scrolling=""no"" frameborder=""0"" style=""border:none; " & _
                   "overflow:hidden; width:" & Width.Value & "px; height:80px;"" allowTransparency=""true""></iframe>"
            writer.Write(text)
        End Sub

    End Class

#End Region

#Region "Diseñadores"

    Public Class ActivityDesigner
        Inherits ControlDesigner

        Public Overrides Function GetDesignTimeHtml() As String
            Dim out As String = ""
            out = String.Format("<button style=""color: Black; background-color: #F7F7F7; font-size: 8pt;"">fbf:<strong>Activity</strong></button>")
            Return out
        End Function

    End Class

    Public Class RecommendationsDesigner
        Inherits ControlDesigner

        Public Overrides Function GetDesignTimeHtml() As String
            Dim out As String = ""
            out = String.Format("<button style=""color: Black; background-color: #F7F7F7; font-size: 8pt;"">fbf:<strong>Recommendations</strong></button>")
            Return out
        End Function

    End Class

    Public Class CommentsDesigner
        Inherits ControlDesigner

        Public Overrides Function GetDesignTimeHtml() As String
            Dim out As String = ""
            out = String.Format("<button style=""color: Black; background-color: #F7F7F7; font-size: 8pt;"">fbf:<strong>Comments</strong></button>")
            Return out
        End Function

    End Class

    Public Class SendDesigner
        Inherits ControlDesigner

        Public Overrides Function GetDesignTimeHtml() As String
            Dim out As String = ""
            out = String.Format("<button style=""color: Black; background-color: #F7F7F7; font-size: 8pt;"">fbf:<strong>Send</strong></button>")
            Return out
        End Function

    End Class

    Public Class SuscribeDesigner
        Inherits ControlDesigner

        Public Overrides Function GetDesignTimeHtml() As String
            Dim out As String = ""
            out = String.Format("<button style=""color: Black; background-color: #F7F7F7; font-size: 8pt;"">fbf:<strong>Suscribe</strong></button>")
            Return out
        End Function

    End Class

    Public Class LikeBoxDesigner
        Inherits ControlDesigner

        Public Overrides Function GetDesignTimeHtml() As String
            Dim out As String = ""
            out = String.Format("<button style=""color: Black; background-color: #F7F7F7; font-size: 8pt;"">fbf:<strong>LikeBox</strong></button>")
            Return out
        End Function

    End Class

    Public Class LikeButtonDesigner
        Inherits ControlDesigner

        Public Overrides Function GetDesignTimeHtml() As String
            Dim out As String = ""
            out = String.Format("<button style=""color: Black; background-color: #F7F7F7; font-size: 8pt;"">fbf:<strong>LikeButton</strong></button>")
            Return out
        End Function

    End Class

#End Region

End Namespace